package com.ruoyi.project.module.ossFileCache.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.module.ossFileCache.domain.OssFileCache;
import com.ruoyi.project.module.ossFileCache.service.IOssFileCacheService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.framework.web.domain.AjaxResult;

/**
 * OSS 缓存 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-05-06
 */
@Controller
@RequestMapping("/module/ossFileCache")
public class OssFileCacheController extends BaseController
{
    private String prefix = "module/ossFileCache";
	
	@Autowired
	private IOssFileCacheService ossFileCacheService;
	
	@RequiresPermissions("module:ossFileCache:view")
	@GetMapping()
	public String ossFileCache()
	{
	    return prefix + "/ossFileCache";
	}
	
	/**
	 * 查询OSS 缓存列表
	 */
	@RequiresPermissions("module:ossFileCache:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(OssFileCache ossFileCache)
	{
		startPage();
        List<OssFileCache> list = ossFileCacheService.selectOssFileCacheList(ossFileCache);
		return getDataTable(list);
	}
	

	/**
	 * 创建 缓存
	 */
	@RequiresPermissions("module:ossFileCache:add")
	@Log(title = "OSS 缓存", businessType = BusinessType.INSERT)
	@PostMapping("/createCache")
	@ResponseBody
	public AjaxResult createCache()
	{		
		return toAjax(ossFileCacheService.createCache());
	}



	/**
	 * 新增保存OSS 缓存
	 */
	@RequiresPermissions("module:ossFileCache:add")
	@Log(title = "OSS 缓存", businessType = BusinessType.INSERT)
	@PostMapping("/clearCache")
	@ResponseBody
	public AjaxResult clearCache()
	{
		return toAjax(ossFileCacheService.deleteOssFileCache());
	}

	
}
